home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1997 August / Walnut Creek CDROM.7z / VOL_400 / 460_01 / UI / PIEWEDGE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-11  |  5.9 KB  |  169 lines

  1.  
  2.  
  3. #ifndef _piewedge_h_ /* Thu Jan  5 09:34:33 1995 */
  4. #define _piewedge_h_
  5.  
  6.  
  7.  
  8. /*
  9.  *
  10.  *          Copyright (C) 1995, M. A. Sridhar
  11.  *  
  12.  *
  13.  *     This software is Copyright M. A. Sridhar, 1995. You are free
  14.  *     to copy, modify or distribute this software  as you see fit,
  15.  *     and to use  it  for  any  purpose, provided   this copyright
  16.  *     notice and the following   disclaimer are included  with all
  17.  *     copies.
  18.  *
  19.  *                        DISCLAIMER
  20.  *
  21.  *     The author makes no warranties, either expressed or implied,
  22.  *     with respect  to  this  software, its  quality, performance,
  23.  *     merchantability, or fitness for any particular purpose. This
  24.  *     software is distributed  AS IS.  The  user of this  software
  25.  *     assumes all risks  as to its quality  and performance. In no
  26.  *     event shall the author be liable for any direct, indirect or
  27.  *     consequential damages, even if the  author has been  advised
  28.  *     as to the possibility of such damages.
  29.  *
  30.  */
  31.  
  32.  
  33.  
  34. // This is a GraphicObject representing a pie wedge of an ellipse, made up
  35. // of an arc and lines joining the ends of the arc to the center. This is a
  36. // closed figure.
  37. //
  38. // Like the other GraphicObjects, the PieWedge views its co-ordinate space as
  39. // an abstract space not tied to any particular device. But its {\tt DrawOn}
  40. // and {\tt Fill} methods view its dimension units as pixels.
  41.  
  42. #if defined(__GNUC__)
  43. #pragma interface
  44. #endif
  45.  
  46.  
  47. #include "ui/arc.h"
  48.  
  49.  
  50. class YACL_UI UI_Arc;
  51. class YACL_UI UI_Ellipse;
  52.  
  53. class YACL_UI UI_PieWedge: public UI_GraphicObject {
  54.  
  55. public:
  56.     UI_PieWedge (const UI_Rectangle& boundingRect, long startAngleDeg64, long
  57.                  subtendedDeg64);
  58.     // Construct a pie wedge of an ellipse. The PieWedge is part of the
  59.     // ellipse whose
  60.     // bounding rectangle is {\tt boundingRect}. Its starting point is at an
  61.     // angle {$d$} degrees from the 3-o'clock position of {\tt boundingRect}
  62.     // where $d = {\tt startAngleDeg64} * 64$, and it subtends an angle $s$
  63.     // at the center of the ellipse, where $s = {\tt subtendedDeg64} * 64$,
  64.  
  65.     UI_PieWedge (const UI_Point &p1, const UI_Point &p2,
  66.                  const UI_Point& origin);
  67.     // Construct an arc of an ellipse with the points p1, p2 being the
  68.     // start point and the end point and the origin being the center of
  69.     // the ellipse.
  70.  
  71.     UI_PieWedge ();
  72.     // Default constructor: construct a piewedge of an ellipse with zero
  73.     // axes.
  74.     
  75.     UI_PieWedge (const UI_PieWedge& w) {*this = w;};
  76.     // Copy constructor.
  77.     
  78.     bool DrawOn (UI_DrawingSurface& sfc,
  79.                  const UI_Point& p = UI_Point (0,0)) const;
  80.     // Draw the ellipse on the surface {\tt sfc} (overrides inherited
  81.     // method).
  82.  
  83.     bool Fill (UI_DrawingSurface& sfc) const;
  84.     // Fill the interior of this PieWedge on the surface {\tt sfc} with the
  85.     // latter's current brush. Return TRUE on success.
  86.     
  87.     bool ReshapeTo (const UI_Point& p1, const UI_Point& p2);
  88.     // Override method inherited from GraphicObject. The implementation
  89.     // reshapes the ellipse so that its bounding rectangle is the rectangle
  90.     // whose diagonally opposite points are p1 and p2.
  91.  
  92.     UI_Rectangle BoundingRectangle() const;
  93.     // Returns the bounding rectangle of the ellipse of which this pie wedge
  94.     // is part.
  95.  
  96.     UI_PointPair EndPoints() const;
  97.     // Return the end-points of the arc of the pie wedge. (See {\tt
  98.     // ui/point.h} for the declaration of {\tt UI_PointPair}).
  99.  
  100.     UI_HitTest HitTest (const UI_Point& p) const;
  101.     // Hit testing: overrides method inherited from Graphic. Return one of
  102.     // the HitTest enumeration values according to whether {\tt p} is
  103.     // inside, outside or on the periphery of this PieWedge.
  104.     
  105.     bool IntersectsBoundary (const UI_Rectangle& r) const;
  106.     // Return TRUE if {\tt r} intersects the boundary of this PieWedge. This
  107.     // overrides the inherited method.
  108.     
  109.     UI_PieWedge operator+  (const UI_Vector&) const;
  110.     // Return the PieWedge obtained by translating this PieWedge by the
  111.     // given vector.
  112.  
  113.     void operator+= (const UI_Vector& p) {*this = *this + p;};
  114.     // Translate this PieWedge by Vector {\tt p}.
  115.  
  116.     bool MoveTo (const UI_Point& p);
  117.     // Move this PieWedge so that the center of its ellipse is at {\tt p}.
  118.     // Return TRUE if successful, FALSE if a pre-change dependent refused
  119.     // permission.
  120.     
  121.     void operator= (const CL_Object& o);
  122.     // Cast {\tt o} down to a PieWedge and assign it to this object.
  123.  
  124.     virtual UI_PieWedge& operator= (const UI_PieWedge& w);
  125.     // Assign {\tt w} to this object.
  126.     
  127.     long StartAngle() const {return _startAngle;};
  128.     // Return the start angle of the pie wedge, reckoned from the 3-o'clock
  129.     // position in sixty-fourths of a degree.
  130.  
  131.     long SubtendedAngle() const {return _subtAngle;};
  132.     // Return the subtended angle of the pie wedge in sixty-fourths of a
  133.     // degree.
  134.  
  135.     UI_Ellipse Ellipse() const;
  136.     // Return the Ellipse of which this PieWedge is part.
  137.  
  138.     virtual bool StartAngle (long startAngle64);
  139.     // Set the start angle of this PieWedge. The parameter is in
  140.     // sixty-fourths of a degree. Return TRUE on success, FALSE on failure
  141.     // (e.g., a pre-change dependent refused permission).
  142.  
  143.     virtual bool SubtendedAngle (long subtAngle64);
  144.     // Set the subtended angle of this PieWedge. The parameter is in
  145.     // sixty-fourths of a degree. Return TRUE on success, FALSE on failure
  146.     // (e.g., a pre-change dependent refused permission).
  147.  
  148.     virtual bool Origin (const UI_Point& origin);
  149.     // Set the center of this PieWedge to {\tt origin}. Return TRUE on
  150.     // success, FALSE on failure (e.g., a pre-change dependent refused
  151.     // permission).
  152.     
  153.     const char* ClassName() const {return "UI_PieWedge";};
  154.  
  155.     CL_Object* Clone () const {return new UI_PieWedge (*this);}
  156.     
  157. protected:
  158.  
  159.     UI_Rectangle _boundingEllipse;
  160.     long         _startAngle  ;
  161.     long         _subtAngle   ;
  162.     UI_Arc       _arc         ;
  163.  
  164. };
  165.  
  166.  
  167.  
  168. #endif /* _piewedge_h_ */
  169.